package com.rmy.queue.api;

import com.rmy.common.core.controller.BaseController;
import com.rmy.common.core.domain.R;
import com.rmy.queue.domain.QmsCompConfig;
import com.rmy.queue.domain.QmsMainCalledResp;
import com.rmy.queue.service.IQmsCompConfigService;
import com.rmy.queue.service.IQmsMainBusinessService;
import com.rmy.system.service.ISysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 外部接口 不需要授权
 */
@Api("综合屏服务接口")
@RestController
@RequestMapping("/queue/api")
public class WebCompController extends BaseController {

    @Autowired
    private IQmsMainBusinessService qmsMainBusinessService;

    @Autowired
    private IQmsCompConfigService qmsCompConfigService;

    @Autowired
    private ISysConfigService configService;


    @ApiOperation("根据机构码获取已叫号列表")
    @ApiImplicitParam(name = "orgno", value = "机构码", required = true, dataType = "String", paramType = "path", dataTypeClass = Integer.class)
    @GetMapping("/selectCalledNoByOrgNo/{orgno}")
    public R<List<QmsMainCalledResp>> selectCalledNoByOrgNo(@PathVariable String orgno)
    {
        List<QmsMainCalledResp> list = qmsMainBusinessService.selectMainCalledListByOrgNo(orgno);
        return R.ok(list);
    }

    @ApiOperation("根据机构码获取等待叫号列表")
    @ApiImplicitParam(name = "orgno", value = "机构码", required = true, dataType = "String", paramType = "path", dataTypeClass = Integer.class)
    @GetMapping("/selectMainWaitCallByOrgNo/{orgno}")
    public R<List<QmsMainCalledResp>> selectMainWaitCallByOrgNo(@PathVariable String orgno)
    {
        List<QmsMainCalledResp> list = qmsMainBusinessService.selectMainWaitCallByOrgNo(orgno);
        return R.ok(list);
    }

    @ApiOperation("根据ID获取综合屏配置信息")
    @ApiImplicitParam(name = "orgno", value = "机构码", required = true, dataType = "String", paramType = "path", dataTypeClass = Long.class)
    @GetMapping("/selectCompConfigInfo/{compId}")
    public R<QmsCompConfig> selectCompConfigInfo(@PathVariable Long compId)
    {
        QmsCompConfig res = qmsCompConfigService.selectQmsCompConfigById(compId);
        String nearNum = configService.selectConfigByKey("qms.comp.nearNum");
        res.setNearNum(nearNum);
        return R.ok(res);
    }

}
